package com.apt.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.apt.common.AptException;
import com.apt.common.DBUtility;
import com.apt.domain.InstitutionMaster;

public class TestTypeMasterDao extends BaseConnection {

	public TestTypeMasterDao(Connection conn) {
		super(conn);

	}

	public Map<Integer,String> getTestTypes() throws AptException {
		Map<Integer,String> testTypes = new HashMap<Integer,String>();
		try {

			PreparedStatement ps = connection
					.prepareStatement("SELECT TEST_TYPE_ID,NAME FROM TEST_TYPE_MASTER");

			ResultSet rs = ps.executeQuery();
			while (rs.next()) {

				testTypes.put(rs.getInt(1),rs.getString(2));

			}
			rs.close();

		} catch (SQLException sqlEx) {
			sqlEx.printStackTrace();
			throw new AptException(
					"Unable to get test types from the database");

		} finally {
			DBUtility.cleanUp(connection);

		}

		return testTypes;

	}

}
